package com.splic.product.service.impl;

import java.util.Date;
import java.util.List;
import com.splic.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.splic.product.mapper.UserActiveMapper;
import com.splic.product.domain.UserActive;
import com.splic.product.service.UserActiveService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 用户活跃Service业务层处理
 * 
 * @author singe
 * @date 2022-01-04
 */
@Service
public class UserActiveServiceImpl implements UserActiveService
{
    @Autowired
    private UserActiveMapper userActiveMapper;

    /**
     * 查询用户活跃
     * 
     * @param id 用户活跃主键
     * @return 用户活跃
     */
    @Override
    public UserActive selectUserActiveById(Long id)
    {
        return userActiveMapper.selectUserActiveById(id);
    }

    /**
     * 查询用户活跃列表
     * 
     * @param userActive 用户活跃
     * @return 用户活跃
     */
    @Override
    public List<UserActive> selectPageList(UserActive userActive)
    {
        return userActiveMapper.selectUserActiveList(userActive);
    }

    /**
     * 查询用户活跃列表
     *
     * @param userActive 用户活跃
     * @return 用户活跃
     */
    @Override
    public List<UserActive> selectUserActiveList(UserActive userActive)
    {
        return userActiveMapper.selectUserActiveList(userActive);
    }

    /**
     * 新增用户活跃
     * 
     * @param userActive 用户活跃
     * @return 结果
     */
    @Override
    public int insert(UserActive userActive)
    {
        userActive.setCreateTime(DateUtils.getNowDate());
        return userActiveMapper.insert(userActive);
    }

    /**
     * 修改用户活跃
     * 
     * @param userActive 用户活跃
     * @return 结果
     */
    @Override
    public int update(UserActive userActive)
    {
        userActive.setUpdateTime(DateUtils.getNowDate());
        return userActiveMapper.update(userActive);
    }


    /**
     * 删除用户活跃信息
     * 
     * @param id 用户活跃主键
     * @return 结果
     */
    @Override
    public int deleteById(Long id)
    {
        return userActiveMapper.deleteById(id);
    }
    /**
     * 修改用户活跃
     *
     * @param userActive 用户活跃信息
     * @return 结果
     */
    @Override
    @Transactional
    public int saveOrUpdate(UserActive userActive)
    {
        if(userActive.getId() != null){
            userActive.setUpdateTime(new Date());
            return userActiveMapper.update(userActive);
        }else{
            userActive.setCreateTime(new Date());
            return userActiveMapper.insert(userActive);
        }
    }
}
